package three;


/**
 *          抽象的意义
 *
 * （1）封装共有的属性和行为------------------代码复用
 * （2）可以包含抽象方法，为所有派生类统一入口(名字统一)，强制必须重写
 */

abstract class Animal {
    String name;
    int age;
    String color;
    Animal(String name,int age,String color){
        this.name = name;
        this.age = age;
        this.color = color;
    }
    abstract void eat();
    void drink(){
        System.out.println(color + "色的" + age + "岁的" + name + "正在drink");
    }


}
class Dog extends Animal {
    Dog(String name, int age, String color) {

        super(name, age, color);
    }

    void lookHome() {
        System.out.println(color + "色的" + age + "岁的狗狗" + name + "正在看家...");
    }

    void eat() {
        System.out.println(color + "色的" + age + "岁的狗狗" + name + "正在吃肯头...");
    }
}

public class Abstract {
    public static void main(String[] args) {
        Animal dog = new Dog("qt",5,"white");
        dog.eat();
        dog.drink();
        Dog dog1 = new Dog("mn",6,"black");
        dog1.lookHome();
        dog1.eat();
        // Animal chick = new Animal() {}   //抽象类不能被实例化

    }

}
